#ifndef STREAMRECORDERCONTROLLER_H
#define STREAMRECORDERCONTROLLER_H

#include "streamrecorderconfig.h"
#include <QObject>
#include <QPointer>
#include <QThread>

class StreamRecorder;

class StreamRecorderController : public QObject
{
    Q_OBJECT
public:
    explicit StreamRecorderController(int id, QObject* parent = nullptr);
    ~StreamRecorderController();

    int id() const { return id_; }
    bool isRunning() const;
    void start(const StreamRecorderConfig& config);
    void stop();
    void terminate();

Q_SIGNALS:
    void positionChanged(qint64 pos);
    void qosMetrics(double fps, double bitrate);
    void finished(const QString& filename, qint64 duration);
    void errorOccurred(int error, const QString& message);

    void startRequested(QPrivateSignal);
    void stopRequested(QPrivateSignal);
    void terminateRequested(QPrivateSignal);

private:
    int id_;
    QThread thread_;
    QPointer<StreamRecorder> stream_recorder_;
};

#endif // STREAMRECORDERCONTROLLER_H
